<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../static/vue.js"></script>
    <script src="../static/axios.js"></script>
    <script src="../static/util.js"></script>
</head>
<body>
<div id="app">
    <table>
        <tr v-for="item,index in list">
            <td>{{item.name}}<button @click="save(item.name)">点赞</button></td>
            <td>得票数：{{item.num}}</td>
            <td>排名:{{index+1}}</td>
        </tr>
    </table>
</div>
<script>
    new Vue({
        el:"#app",
        data:{
            list:{}
        },
        created(){
            this.findAll()
        },
        methods:{
            save(name){
                axios.get("http://localhost:8884/emp/dian?name="+name).then(res=>{
                    this.findAll();
                })
            },
            findAll(){
                axios.get("http://localhost:8884/emp/findAll").then(res=>{
                    this.list=res.data
                })
            }
        }
    })
</script>
</body>
</html>